package com.example.himalaya.view_component;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Path;
import android.graphics.RectF;
import android.util.AttributeSet;

import androidx.appcompat.widget.AppCompatImageView;

public class RoundRectImageView extends AppCompatImageView {

    private float rountRatio = 0.1f;

    private Path path;


    public RoundRectImageView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
    }


    @Override
    protected void onDraw(Canvas canvas) {
        if(path == null) {
            path = new Path();
            path.addRoundRect(new RectF(0, 0, getWidth(), getHeight()), rountRatio * getWidth(), rountRatio * getHeight(), Path.Direction.CW);
        }

        canvas.save();
        canvas.clipPath(path);
        super.onDraw(canvas);
        canvas.restore();
    }
}
